package com.iaz.tech.tools.common.flow.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iaz.tech.tools.common.flow.IFlowAble;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * while 循环语句，表达式
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class WhileFlow extends FlowsGroup {
	/**
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(WhileFlow.class);
    private IFlowAble boundary = null;
	/**
     * 执行流程
     */
    @Override
    public Object executeFlow(Object property) {
        Object result = null;
        try {
            if (this.boundary == null) {
                logger.warn("ForFlow boundaries is null or empty");
                return result;
            }
            // 循环条件
            if ((Boolean)this.boundary.executeFlow(property)) {
                // 执行循环体 
                result = super.executeFlow(property);
            }
        } catch (Exception e) {
            logger.error("ForFlow executeFlow error", e);
        }
        return result;
    }    
}

